package com.burstly.lib.component.networkcomponent.burstly.html;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.res.Configuration;
import android.media.MediaPlayer;
import android.media.MediaPlayer.OnCompletionListener;
import android.media.MediaPlayer.OnErrorListener;
import android.media.MediaPlayer.OnPreparedListener;
import android.os.Build.VERSION;
import android.view.MotionEvent;
import android.widget.FrameLayout;
import android.widget.FrameLayout.LayoutParams;
import android.widget.MediaController;
import android.widget.VideoView;
import com.burstly.lib.component.networkcomponent.burstly.AudioControlReciever;
import com.burstly.lib.component.networkcomponent.burstly.NoSeekMediaController;
import com.burstly.lib.util.Utils;

@SuppressLint({"NewApi"})
public class VideoViewPane extends FrameLayout
{
  final AudioControlReciever mAudioControl;
  NoSeekMediaController mController;
  private FrameLayout mProgressDialog;
  boolean mVideoRestarted;
  private String mVideoUrl;
  private volatile VideoView mVideoView;

  public VideoViewPane(Context paramContext)
  {
    super(paramContext);
    setBackgroundColor(-16777216);
    if (Build.VERSION.SDK_INT >= 8);
    for (Object localObject = new VideoView(paramContext)
    {
      protected void onConfigurationChanged(Configuration paramAnonymousConfiguration)
      {
        super.onConfigurationChanged(paramAnonymousConfiguration);
        VideoViewPane.this.getMediaController().hide();
      }
    }
    ; ; localObject = new VideoView(paramContext))
    {
      this.mVideoView = ((VideoView)localObject);
      this.mVideoView.setZOrderMediaOverlay(true);
      this.mVideoView.setMediaController(getMediaController());
      int i = Utils.getFillparentValue();
      addView(this.mVideoView, new FrameLayout.LayoutParams(i, i, 17));
      this.mProgressDialog = new LoadingBarView(getContext());
      this.mProgressDialog.setBackgroundColor(-16777216);
      addView(this.mProgressDialog, new FrameLayout.LayoutParams(i, i, 17));
      this.mAudioControl = new AudioControlReciever(paramContext);
      return;
    }
  }

  public void destroy()
  {
    hideProgress();
    this.mAudioControl.unRegisterReciever();
    this.mVideoView.stopPlayback();
  }

  public AudioControlReciever getAudioControl()
  {
    return this.mAudioControl;
  }

  public MediaController getController()
  {
    return getMediaController();
  }

  protected MediaController getMediaController()
  {
    if (this.mController == null)
      this.mController = new NoSeekMediaController(getContext());
    return this.mController;
  }

  public FrameLayout getProgressDialog()
  {
    return this.mProgressDialog;
  }

  String getVideoUrl()
  {
    return this.mVideoUrl;
  }

  public VideoView getVideoView()
  {
    return this.mVideoView;
  }

  public void hideProgress()
  {
    removeView(this.mProgressDialog);
  }

  public boolean onTouchEvent(MotionEvent paramMotionEvent)
  {
    return true;
  }

  public void playVideo(String paramString)
  {
    this.mAudioControl.registerReciever();
    this.mVideoUrl = paramString;
    this.mVideoRestarted = false;
    this.mVideoView.setVideoPath(paramString);
    this.mVideoView.start();
  }

  public void restartVideo()
  {
    this.mVideoRestarted = true;
    this.mVideoView.stopPlayback();
    this.mVideoView.setVideoPath(this.mVideoUrl);
    this.mVideoView.pause();
  }

  public void setListeners(final MediaPlayer.OnPreparedListener paramOnPreparedListener, MediaPlayer.OnCompletionListener paramOnCompletionListener, MediaPlayer.OnErrorListener paramOnErrorListener)
  {
    if (paramOnPreparedListener != null)
      this.mVideoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener()
      {
        public void onPrepared(MediaPlayer paramAnonymousMediaPlayer)
        {
          VideoViewPane.this.mAudioControl.setMediaPlayer(paramAnonymousMediaPlayer);
          VideoViewPane.this.hideProgress();
          VideoViewPane.this.getMediaController().show();
          if (!VideoViewPane.this.mVideoRestarted)
            paramOnPreparedListener.onPrepared(paramAnonymousMediaPlayer);
        }
      });
    if (paramOnErrorListener != null)
      this.mVideoView.setOnErrorListener(paramOnErrorListener);
    if (paramOnCompletionListener != null)
      this.mVideoView.setOnCompletionListener(paramOnCompletionListener);
  }

  public void setProgressDialog(FrameLayout paramFrameLayout)
  {
    this.mProgressDialog = paramFrameLayout;
  }

  public void setVideoView(VideoView paramVideoView)
  {
    this.mVideoView = paramVideoView;
  }
}

/* Location:           E:\android\Toy Defense 2_dex2jar.jar
 * Qualified Name:     com.burstly.lib.component.networkcomponent.burstly.html.VideoViewPane
 * JD-Core Version:    0.6.2
 */